#CROSS_COMPILE是环境变量，是交叉编译工具的前缀，隐式声明编译器
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++

#显示声明编译器
#CC = arm-fsl-linux-gnueabi-gcc
#CXX = arm-fsl-linux-gnueabi-g++

CXXFLAGS = -Wall -g
CFLAGS=-I ./ -Wall -Werror
LDFLAGS=-static

OBJS = main.o ssd1306.o linux_i2c.o
EXEC = $(IMX28_exe_DIR)ssd1306_bin

default: $(EXEC)
.PHONY: default clean

# Adapted from scottmcpeak.com/autodepend/autodepend.html
-include $(OBJS:.o=.d)
%.o: %.c
	$(CC) -c $(CFLAGS) $< -o $*.o
	$(CC) -MM $(CFLAGS) $< > $*.d
	@cp -f $*.d $*.d.tmp
	@sed -e 's/.*://' -e 's/\\$$//' < $*.d.tmp | fmt -1 | \
	  sed -e 's/^ *//' -e 's/$$/:/' >> $*.d
	@rm -f $*.d.tmp

$(EXEC):$(OBJS)
	$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)

install:
	cp $(EXEC) $(IMX28_exe_DIR)
clean:
	rm -f *.o *.d $(EXEC)

